﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data;

/// <summary>
/// Summary description for CheckOutService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class CheckOutService : System.Web.Services.WebService {

    public CheckOutService () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    private Database db = DatabaseFactory.CreateDatabase("cns");
    [WebMethod]
    public DataTable GetPaymentType()
    {
        DataTable table = new DataTable();
        table.TableName = "paymenttype";
        var paymenttype = db.ExecuteDataSet(CommandType.StoredProcedure, "sp_GetPaymentType");
        if (paymenttype.Tables.Count >= 0)
            table = paymenttype.Tables[0];
        return table;
    }

    [WebMethod]
    public DataTable GetColumnData()
    {
        DataTable table = new DataTable();
        table.TableName = "columndata";
        var columndata = db.ExecuteDataSet(CommandType.StoredProcedure, "sp_GetColumnData");
        if (columndata.Tables.Count >= 0)
            table = columndata.Tables[0];
        return table;
    }

    [WebMethod]
    public int UpdateCheckout(int ReservationNo,
                            string FirstName,
                            string LastName,
                            int Gender,
                            string GuestTypeID,
                            string CompanyID,
                            string Phone,
                            string Mobile,
                            int Adult,
                            int Child,
                            DateTime CheckIn,
                            DateTime CheckOut,
                            string ReserveTypeID,
                            string RoomTypeID,
                            string RoomsPerType,
                            int Rooms,
                            string RoomNumber,
                            string PaymentTypeID,
                            int CardTypeID,
                            string CardNo,
                            string Cashier,
                            string Status)
    {
        int result = db.ExecuteNonQuery("sp_UpdateReservationStatus", ReservationNo,
                                                                        FirstName,
                                                                        LastName,
                                                                        Gender,
                                                                        CompanyID,
                                                                        GuestTypeID,
                                                                        Phone,
                                                                        Mobile,
                                                                        Adult,
                                                                        Child,
                                                                        CheckIn,
                                                                        CheckOut,
                                                                        ReserveTypeID,
                                                                        RoomTypeID,
                                                                        RoomsPerType,
                                                                        Rooms,
                                                                        RoomNumber,
                                                                        PaymentTypeID,
                                                                        CardTypeID,
                                                                        CardNo,
                                                                        Cashier,
                                                                        Status
                                                                        );
        return result;
    }

    [WebMethod]
    public DataTable StatusFilter(string status)
    {
        DataTable table = new DataTable();
        table.TableName = "statuscolumn";
        var columndatastatus = db.ExecuteDataSet("sp_StatusFilter", status);
        if (columndatastatus.Tables.Count >= 0)
            table = columndatastatus.Tables[0];
        return table;
    }

    [WebMethod]
    public DataTable SearchByName(string LastName)
    {
        DataTable table = new DataTable();
        table.TableName = "SearchByName";
        var SearchName = db.ExecuteDataSet("sp_SearchByGuestName", LastName);
        if (SearchName.Tables.Count >= 0)
            table = SearchName.Tables[0];
        return table;
    }



    [WebMethod]
    public int UpdateReservation(int ReservationNo,
                                string FirstName,
                            string LastName,
                            int Gender,
                            string GuestTypeID,
                            string CompanyID,
                            string Phone,
                            string Mobile,
                            int Adult,
                            int Child,
                            DateTime CheckIn,
                            DateTime CheckOut,
                            string ReserveTypeID,
                            string RoomTypeID,
                            string RoomsPerType,
                            int Rooms,
                            string RoomNumber,
                            string PaymentTypeID,
                            int CardTypeID,
                            string CardNo,
                            int Cashier
                          )
    {
        int result = db.ExecuteNonQuery("sp_UpdateReservation", ReservationNo, FirstName, LastName, Gender, CompanyID, GuestTypeID, Phone, Mobile, Adult, Child, CheckIn, CheckOut, ReserveTypeID, RoomTypeID, RoomsPerType, Rooms, RoomNumber, PaymentTypeID, CardTypeID, CardNo, Cashier);
        return result;
    }

    [WebMethod]
    public DataTable CheckoutEdit(int ReservatioNo)
    {
        DataTable table = new DataTable();
        table.TableName = "tableckedit";
        var columndatastatus = db.ExecuteDataSet("sp_EditReservation", ReservatioNo);
        if (columndatastatus.Tables.Count >= 0)
            table = columndatastatus.Tables[0];
        return table;

    }

    [WebMethod]
    public DataTable GetGuestType()
    {
        DataTable guesttable = new DataTable();
        guesttable.TableName = "GuestType";
        var Guesttype = db.ExecuteDataSet(CommandType.StoredProcedure, "sp_GetGuestType");
        if (Guesttype.Tables.Count >= 0)
            guesttable = Guesttype.Tables[0];
        return guesttable;
    }

    [WebMethod]
    public DataTable GetEmployee()
    {
        DataTable Employeetable = new DataTable();
        Employeetable.TableName = "Employee";
        var Employee = db.ExecuteDataSet(CommandType.StoredProcedure, "sp_GetEmployee");
        if (Employee.Tables.Count >= 0)
            Employeetable = Employee.Tables[0];
        return Employeetable;
    }

    [WebMethod]
    public DataTable GetCardType()
    {
        DataTable CardTypetable = new DataTable();
        CardTypetable.TableName = "CardType";
        var CardType = db.ExecuteDataSet(CommandType.StoredProcedure, "sp_GetCardType");
        if (CardType.Tables.Count >= 0)
            CardTypetable = CardType.Tables[0];
        return CardTypetable;
    }

    public DataTable ReserveType()
    {
        DataTable ReserveTypetable = new DataTable();
        ReserveTypetable.TableName = "ReserveType";
        var ReserveType = db.ExecuteDataSet(CommandType.StoredProcedure, "sp_GetReserveType");
        if (ReserveType.Tables.Count >= 0)
            ReserveTypetable = ReserveType.Tables[0];
        return ReserveTypetable;
    }

    [WebMethod]
    public DataTable RoomType()
    {
        DataTable RoomTypetable = new DataTable();
        RoomTypetable.TableName = "RoomType";
        var RoomType = db.ExecuteDataSet(CommandType.StoredProcedure, "sp_GetRoomType");
        if (RoomType.Tables.Count >= 0)
            RoomTypetable = RoomType.Tables[0];
        return RoomTypetable;
    }
}
